/**
 * This is a generated class and is not intended for modification.  To customize behavior
 * of this value object you may modify the generated sub-class of this class - PatientGeneralInfo.as.
 */

package valueObjects
{
import com.adobe.fiber.services.IFiberManagingService;
import com.adobe.fiber.util.FiberUtils;
import com.adobe.fiber.valueobjects.IValueObject;
import flash.events.Event;
import flash.events.EventDispatcher;
import mx.binding.utils.ChangeWatcher;
import mx.events.PropertyChangeEvent;
import mx.validators.ValidationResult;
import valueObjects.PatientPersonalInfo;

import flash.net.registerClassAlias;
import flash.net.getClassByAlias;
import com.adobe.fiber.core.model_internal;
import com.adobe.fiber.valueobjects.IPropertyIterator;
import com.adobe.fiber.valueobjects.AvailablePropertyIterator;

use namespace model_internal;

[ExcludeClass]
public class _Super_PatientGeneralInfo extends flash.events.EventDispatcher implements com.adobe.fiber.valueobjects.IValueObject
{
    model_internal static function initRemoteClassAliasSingle(cz:Class) : void
    {
    }

    model_internal static function initRemoteClassAliasAllRelated() : void
    {
        valueObjects.PatientPersonalInfo.initRemoteClassAliasSingleChild();
    }

    model_internal var _dminternal_model : _PatientGeneralInfoEntityMetadata;

    /**
     * properties
     */
    private var _internal_addressLine1 : String;
    private var _internal_addressLine2 : String;
    private var _internal_birthCountry : String;
    private var _internal_city : String;
    private var _internal_dateOfBirth : Date;
    private var _internal_email : String;
    private var _internal_ethnicity : String;
    private var _internal_firstName : String;
    private var _internal_homePhone : String;
    private var _internal_id : Number;
    private var _internal_lastName : String;
    private var _internal_middleName : String;
    private var _internal_password : String;
    private var _internal_personalInfo : valueObjects.PatientPersonalInfo;
    private var _internal_sex : String;
    private var _internal_ssn : String;
    private var _internal_state : String;
    private var _internal_username : String;
    private var _internal_workPhone : String;
    private var _internal_zip : Number;

    private static var emptyArray:Array = new Array();


    /**
     * derived property cache initialization
     */
    model_internal var _cacheInitialized_isValid:Boolean = false;

    model_internal var _changeWatcherArray:Array = new Array();

    public function _Super_PatientGeneralInfo()
    {
        _model = new _PatientGeneralInfoEntityMetadata(this);

        // Bind to own data properties for cache invalidation triggering
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "addressLine1", model_internal::setterListenerAddressLine1));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "addressLine2", model_internal::setterListenerAddressLine2));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "birthCountry", model_internal::setterListenerBirthCountry));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "city", model_internal::setterListenerCity));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "dateOfBirth", model_internal::setterListenerDateOfBirth));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "email", model_internal::setterListenerEmail));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "ethnicity", model_internal::setterListenerEthnicity));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "firstName", model_internal::setterListenerFirstName));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "homePhone", model_internal::setterListenerHomePhone));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "lastName", model_internal::setterListenerLastName));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "middleName", model_internal::setterListenerMiddleName));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "password", model_internal::setterListenerPassword));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "personalInfo", model_internal::setterListenerPersonalInfo));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "sex", model_internal::setterListenerSex));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "ssn", model_internal::setterListenerSsn));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "state", model_internal::setterListenerState));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "username", model_internal::setterListenerUsername));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "workPhone", model_internal::setterListenerWorkPhone));

    }

    /**
     * data property getters
     */

    [Bindable(event="propertyChange")]
    public function get addressLine1() : String
    {
        return _internal_addressLine1;
    }

    [Bindable(event="propertyChange")]
    public function get addressLine2() : String
    {
        return _internal_addressLine2;
    }

    [Bindable(event="propertyChange")]
    public function get birthCountry() : String
    {
        return _internal_birthCountry;
    }

    [Bindable(event="propertyChange")]
    public function get city() : String
    {
        return _internal_city;
    }

    [Bindable(event="propertyChange")]
    public function get dateOfBirth() : Date
    {
        return _internal_dateOfBirth;
    }

    [Bindable(event="propertyChange")]
    public function get email() : String
    {
        return _internal_email;
    }

    [Bindable(event="propertyChange")]
    public function get ethnicity() : String
    {
        return _internal_ethnicity;
    }

    [Bindable(event="propertyChange")]
    public function get firstName() : String
    {
        return _internal_firstName;
    }

    [Bindable(event="propertyChange")]
    public function get homePhone() : String
    {
        return _internal_homePhone;
    }

    [Bindable(event="propertyChange")]
    public function get id() : Number
    {
        return _internal_id;
    }

    [Bindable(event="propertyChange")]
    public function get lastName() : String
    {
        return _internal_lastName;
    }

    [Bindable(event="propertyChange")]
    public function get middleName() : String
    {
        return _internal_middleName;
    }

    [Bindable(event="propertyChange")]
    public function get password() : String
    {
        return _internal_password;
    }

    [Bindable(event="propertyChange")]
    public function get personalInfo() : valueObjects.PatientPersonalInfo
    {
        return _internal_personalInfo;
    }

    [Bindable(event="propertyChange")]
    public function get sex() : String
    {
        return _internal_sex;
    }

    [Bindable(event="propertyChange")]
    public function get ssn() : String
    {
        return _internal_ssn;
    }

    [Bindable(event="propertyChange")]
    public function get state() : String
    {
        return _internal_state;
    }

    [Bindable(event="propertyChange")]
    public function get username() : String
    {
        return _internal_username;
    }

    [Bindable(event="propertyChange")]
    public function get workPhone() : String
    {
        return _internal_workPhone;
    }

    [Bindable(event="propertyChange")]
    public function get zip() : Number
    {
        return _internal_zip;
    }

    /**
     * data property setters
     */

    public function set addressLine1(value:String) : void
    {
        var oldValue:String = _internal_addressLine1;
        if (oldValue !== value)
        {
            _internal_addressLine1 = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "addressLine1", oldValue, _internal_addressLine1));
        }
    }

    public function set addressLine2(value:String) : void
    {
        var oldValue:String = _internal_addressLine2;
        if (oldValue !== value)
        {
            _internal_addressLine2 = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "addressLine2", oldValue, _internal_addressLine2));
        }
    }

    public function set birthCountry(value:String) : void
    {
        var oldValue:String = _internal_birthCountry;
        if (oldValue !== value)
        {
            _internal_birthCountry = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "birthCountry", oldValue, _internal_birthCountry));
        }
    }

    public function set city(value:String) : void
    {
        var oldValue:String = _internal_city;
        if (oldValue !== value)
        {
            _internal_city = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "city", oldValue, _internal_city));
        }
    }

    public function set dateOfBirth(value:Date) : void
    {
        var oldValue:Date = _internal_dateOfBirth;
        if (oldValue !== value)
        {
            _internal_dateOfBirth = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "dateOfBirth", oldValue, _internal_dateOfBirth));
        }
    }

    public function set email(value:String) : void
    {
        var oldValue:String = _internal_email;
        if (oldValue !== value)
        {
            _internal_email = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "email", oldValue, _internal_email));
        }
    }

    public function set ethnicity(value:String) : void
    {
        var oldValue:String = _internal_ethnicity;
        if (oldValue !== value)
        {
            _internal_ethnicity = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "ethnicity", oldValue, _internal_ethnicity));
        }
    }

    public function set firstName(value:String) : void
    {
        var oldValue:String = _internal_firstName;
        if (oldValue !== value)
        {
            _internal_firstName = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "firstName", oldValue, _internal_firstName));
        }
    }

    public function set homePhone(value:String) : void
    {
        var oldValue:String = _internal_homePhone;
        if (oldValue !== value)
        {
            _internal_homePhone = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "homePhone", oldValue, _internal_homePhone));
        }
    }

    public function set id(value:Number) : void
    {
        var oldValue:Number = _internal_id;
        if (oldValue !== value)
        {
            _internal_id = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "id", oldValue, _internal_id));
        }
    }

    public function set lastName(value:String) : void
    {
        var oldValue:String = _internal_lastName;
        if (oldValue !== value)
        {
            _internal_lastName = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "lastName", oldValue, _internal_lastName));
        }
    }

    public function set middleName(value:String) : void
    {
        var oldValue:String = _internal_middleName;
        if (oldValue !== value)
        {
            _internal_middleName = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "middleName", oldValue, _internal_middleName));
        }
    }

    public function set password(value:String) : void
    {
        var oldValue:String = _internal_password;
        if (oldValue !== value)
        {
            _internal_password = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "password", oldValue, _internal_password));
        }
    }

    public function set personalInfo(value:valueObjects.PatientPersonalInfo) : void
    {
        var oldValue:valueObjects.PatientPersonalInfo = _internal_personalInfo;
        if (oldValue !== value)
        {
            _internal_personalInfo = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "personalInfo", oldValue, _internal_personalInfo));
        }
    }

    public function set sex(value:String) : void
    {
        var oldValue:String = _internal_sex;
        if (oldValue !== value)
        {
            _internal_sex = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "sex", oldValue, _internal_sex));
        }
    }

    public function set ssn(value:String) : void
    {
        var oldValue:String = _internal_ssn;
        if (oldValue !== value)
        {
            _internal_ssn = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "ssn", oldValue, _internal_ssn));
        }
    }

    public function set state(value:String) : void
    {
        var oldValue:String = _internal_state;
        if (oldValue !== value)
        {
            _internal_state = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "state", oldValue, _internal_state));
        }
    }

    public function set username(value:String) : void
    {
        var oldValue:String = _internal_username;
        if (oldValue !== value)
        {
            _internal_username = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "username", oldValue, _internal_username));
        }
    }

    public function set workPhone(value:String) : void
    {
        var oldValue:String = _internal_workPhone;
        if (oldValue !== value)
        {
            _internal_workPhone = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "workPhone", oldValue, _internal_workPhone));
        }
    }

    public function set zip(value:Number) : void
    {
        var oldValue:Number = _internal_zip;
        if (oldValue !== value)
        {
            _internal_zip = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "zip", oldValue, _internal_zip));
        }
    }

    /**
     * Data property setter listeners
     *
     * Each data property whose value affects other properties or the validity of the entity
     * needs to invalidate all previously calculated artifacts. These include:
     *  - any derived properties or constraints that reference the given data property.
     *  - any availability guards (variant expressions) that reference the given data property.
     *  - any style validations, message tokens or guards that reference the given data property.
     *  - the validity of the property (and the containing entity) if the given data property has a length restriction.
     *  - the validity of the property (and the containing entity) if the given data property is required.
     */

    model_internal function setterListenerAddressLine1(value:flash.events.Event):void
    {
        _model.invalidateDependentOnAddressLine1();
    }

    model_internal function setterListenerAddressLine2(value:flash.events.Event):void
    {
        _model.invalidateDependentOnAddressLine2();
    }

    model_internal function setterListenerBirthCountry(value:flash.events.Event):void
    {
        _model.invalidateDependentOnBirthCountry();
    }

    model_internal function setterListenerCity(value:flash.events.Event):void
    {
        _model.invalidateDependentOnCity();
    }

    model_internal function setterListenerDateOfBirth(value:flash.events.Event):void
    {
        _model.invalidateDependentOnDateOfBirth();
    }

    model_internal function setterListenerEmail(value:flash.events.Event):void
    {
        _model.invalidateDependentOnEmail();
    }

    model_internal function setterListenerEthnicity(value:flash.events.Event):void
    {
        _model.invalidateDependentOnEthnicity();
    }

    model_internal function setterListenerFirstName(value:flash.events.Event):void
    {
        _model.invalidateDependentOnFirstName();
    }

    model_internal function setterListenerHomePhone(value:flash.events.Event):void
    {
        _model.invalidateDependentOnHomePhone();
    }

    model_internal function setterListenerLastName(value:flash.events.Event):void
    {
        _model.invalidateDependentOnLastName();
    }

    model_internal function setterListenerMiddleName(value:flash.events.Event):void
    {
        _model.invalidateDependentOnMiddleName();
    }

    model_internal function setterListenerPassword(value:flash.events.Event):void
    {
        _model.invalidateDependentOnPassword();
    }

    model_internal function setterListenerPersonalInfo(value:flash.events.Event):void
    {
        _model.invalidateDependentOnPersonalInfo();
    }

    model_internal function setterListenerSex(value:flash.events.Event):void
    {
        _model.invalidateDependentOnSex();
    }

    model_internal function setterListenerSsn(value:flash.events.Event):void
    {
        _model.invalidateDependentOnSsn();
    }

    model_internal function setterListenerState(value:flash.events.Event):void
    {
        _model.invalidateDependentOnState();
    }

    model_internal function setterListenerUsername(value:flash.events.Event):void
    {
        _model.invalidateDependentOnUsername();
    }

    model_internal function setterListenerWorkPhone(value:flash.events.Event):void
    {
        _model.invalidateDependentOnWorkPhone();
    }


    /**
     * valid related derived properties
     */
    model_internal var _isValid : Boolean;
    model_internal var _invalidConstraints:Array = new Array();
    model_internal var _validationFailureMessages:Array = new Array();

    /**
     * derived property calculators
     */

    /**
     * isValid calculator
     */
    model_internal function calculateIsValid():Boolean
    {
        var violatedConsts:Array = new Array();
        var validationFailureMessages:Array = new Array();

        var propertyValidity:Boolean = true;
        if (!_model.addressLine1IsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_addressLine1ValidationFailureMessages);
        }
        if (!_model.addressLine2IsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_addressLine2ValidationFailureMessages);
        }
        if (!_model.birthCountryIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_birthCountryValidationFailureMessages);
        }
        if (!_model.cityIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_cityValidationFailureMessages);
        }
        if (!_model.dateOfBirthIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_dateOfBirthValidationFailureMessages);
        }
        if (!_model.emailIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_emailValidationFailureMessages);
        }
        if (!_model.ethnicityIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_ethnicityValidationFailureMessages);
        }
        if (!_model.firstNameIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_firstNameValidationFailureMessages);
        }
        if (!_model.homePhoneIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_homePhoneValidationFailureMessages);
        }
        if (!_model.lastNameIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_lastNameValidationFailureMessages);
        }
        if (!_model.middleNameIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_middleNameValidationFailureMessages);
        }
        if (!_model.passwordIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_passwordValidationFailureMessages);
        }
        if (!_model.personalInfoIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_personalInfoValidationFailureMessages);
        }
        if (!_model.sexIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_sexValidationFailureMessages);
        }
        if (!_model.ssnIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_ssnValidationFailureMessages);
        }
        if (!_model.stateIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_stateValidationFailureMessages);
        }
        if (!_model.usernameIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_usernameValidationFailureMessages);
        }
        if (!_model.workPhoneIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_workPhoneValidationFailureMessages);
        }

        model_internal::_cacheInitialized_isValid = true;
        model_internal::invalidConstraints_der = violatedConsts;
        model_internal::validationFailureMessages_der = validationFailureMessages;
        return violatedConsts.length == 0 && propertyValidity;
    }

    /**
     * derived property setters
     */

    model_internal function set isValid_der(value:Boolean) : void
    {
        var oldValue:Boolean = model_internal::_isValid;
        if (oldValue !== value)
        {
            model_internal::_isValid = value;
            _model.model_internal::fireChangeEvent("isValid", oldValue, model_internal::_isValid);
        }
    }

    /**
     * derived property getters
     */

    [Transient]
    [Bindable(event="propertyChange")]
    public function get _model() : _PatientGeneralInfoEntityMetadata
    {
        return model_internal::_dminternal_model;
    }

    public function set _model(value : _PatientGeneralInfoEntityMetadata) : void
    {
        var oldValue : _PatientGeneralInfoEntityMetadata = model_internal::_dminternal_model;
        if (oldValue !== value)
        {
            model_internal::_dminternal_model = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "_model", oldValue, model_internal::_dminternal_model));
        }
    }

    /**
     * methods
     */


    /**
     *  services
     */
    private var _managingService:com.adobe.fiber.services.IFiberManagingService;

    public function set managingService(managingService:com.adobe.fiber.services.IFiberManagingService):void
    {
        _managingService = managingService;
    }

    model_internal function set invalidConstraints_der(value:Array) : void
    {
        var oldValue:Array = model_internal::_invalidConstraints;
        // avoid firing the event when old and new value are different empty arrays
        if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
        {
            model_internal::_invalidConstraints = value;
            _model.model_internal::fireChangeEvent("invalidConstraints", oldValue, model_internal::_invalidConstraints);
        }
    }

    model_internal function set validationFailureMessages_der(value:Array) : void
    {
        var oldValue:Array = model_internal::_validationFailureMessages;
        // avoid firing the event when old and new value are different empty arrays
        if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
        {
            model_internal::_validationFailureMessages = value;
            _model.model_internal::fireChangeEvent("validationFailureMessages", oldValue, model_internal::_validationFailureMessages);
        }
    }

    model_internal var _doValidationCacheOfAddressLine1 : Array = null;
    model_internal var _doValidationLastValOfAddressLine1 : String;

    model_internal function _doValidationForAddressLine1(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfAddressLine1 != null && model_internal::_doValidationLastValOfAddressLine1 == value)
           return model_internal::_doValidationCacheOfAddressLine1 ;

        _model.model_internal::_addressLine1IsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isAddressLine1Available && _internal_addressLine1 == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "addressLine1 is required"));
        }

        model_internal::_doValidationCacheOfAddressLine1 = validationFailures;
        model_internal::_doValidationLastValOfAddressLine1 = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfAddressLine2 : Array = null;
    model_internal var _doValidationLastValOfAddressLine2 : String;

    model_internal function _doValidationForAddressLine2(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfAddressLine2 != null && model_internal::_doValidationLastValOfAddressLine2 == value)
           return model_internal::_doValidationCacheOfAddressLine2 ;

        _model.model_internal::_addressLine2IsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isAddressLine2Available && _internal_addressLine2 == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "addressLine2 is required"));
        }

        model_internal::_doValidationCacheOfAddressLine2 = validationFailures;
        model_internal::_doValidationLastValOfAddressLine2 = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfBirthCountry : Array = null;
    model_internal var _doValidationLastValOfBirthCountry : String;

    model_internal function _doValidationForBirthCountry(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfBirthCountry != null && model_internal::_doValidationLastValOfBirthCountry == value)
           return model_internal::_doValidationCacheOfBirthCountry ;

        _model.model_internal::_birthCountryIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isBirthCountryAvailable && _internal_birthCountry == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "birthCountry is required"));
        }

        model_internal::_doValidationCacheOfBirthCountry = validationFailures;
        model_internal::_doValidationLastValOfBirthCountry = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfCity : Array = null;
    model_internal var _doValidationLastValOfCity : String;

    model_internal function _doValidationForCity(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfCity != null && model_internal::_doValidationLastValOfCity == value)
           return model_internal::_doValidationCacheOfCity ;

        _model.model_internal::_cityIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isCityAvailable && _internal_city == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "city is required"));
        }

        model_internal::_doValidationCacheOfCity = validationFailures;
        model_internal::_doValidationLastValOfCity = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfDateOfBirth : Array = null;
    model_internal var _doValidationLastValOfDateOfBirth : Date;

    model_internal function _doValidationForDateOfBirth(valueIn:Object):Array
    {
        var value : Date = valueIn as Date;

        if (model_internal::_doValidationCacheOfDateOfBirth != null && model_internal::_doValidationLastValOfDateOfBirth == value)
           return model_internal::_doValidationCacheOfDateOfBirth ;

        _model.model_internal::_dateOfBirthIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isDateOfBirthAvailable && _internal_dateOfBirth == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "dateOfBirth is required"));
        }

        model_internal::_doValidationCacheOfDateOfBirth = validationFailures;
        model_internal::_doValidationLastValOfDateOfBirth = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfEmail : Array = null;
    model_internal var _doValidationLastValOfEmail : String;

    model_internal function _doValidationForEmail(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfEmail != null && model_internal::_doValidationLastValOfEmail == value)
           return model_internal::_doValidationCacheOfEmail ;

        _model.model_internal::_emailIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isEmailAvailable && _internal_email == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "email is required"));
        }

        model_internal::_doValidationCacheOfEmail = validationFailures;
        model_internal::_doValidationLastValOfEmail = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfEthnicity : Array = null;
    model_internal var _doValidationLastValOfEthnicity : String;

    model_internal function _doValidationForEthnicity(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfEthnicity != null && model_internal::_doValidationLastValOfEthnicity == value)
           return model_internal::_doValidationCacheOfEthnicity ;

        _model.model_internal::_ethnicityIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isEthnicityAvailable && _internal_ethnicity == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "ethnicity is required"));
        }

        model_internal::_doValidationCacheOfEthnicity = validationFailures;
        model_internal::_doValidationLastValOfEthnicity = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfFirstName : Array = null;
    model_internal var _doValidationLastValOfFirstName : String;

    model_internal function _doValidationForFirstName(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfFirstName != null && model_internal::_doValidationLastValOfFirstName == value)
           return model_internal::_doValidationCacheOfFirstName ;

        _model.model_internal::_firstNameIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isFirstNameAvailable && _internal_firstName == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "firstName is required"));
        }

        model_internal::_doValidationCacheOfFirstName = validationFailures;
        model_internal::_doValidationLastValOfFirstName = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfHomePhone : Array = null;
    model_internal var _doValidationLastValOfHomePhone : String;

    model_internal function _doValidationForHomePhone(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfHomePhone != null && model_internal::_doValidationLastValOfHomePhone == value)
           return model_internal::_doValidationCacheOfHomePhone ;

        _model.model_internal::_homePhoneIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isHomePhoneAvailable && _internal_homePhone == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "homePhone is required"));
        }

        model_internal::_doValidationCacheOfHomePhone = validationFailures;
        model_internal::_doValidationLastValOfHomePhone = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfLastName : Array = null;
    model_internal var _doValidationLastValOfLastName : String;

    model_internal function _doValidationForLastName(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfLastName != null && model_internal::_doValidationLastValOfLastName == value)
           return model_internal::_doValidationCacheOfLastName ;

        _model.model_internal::_lastNameIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isLastNameAvailable && _internal_lastName == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "lastName is required"));
        }

        model_internal::_doValidationCacheOfLastName = validationFailures;
        model_internal::_doValidationLastValOfLastName = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfMiddleName : Array = null;
    model_internal var _doValidationLastValOfMiddleName : String;

    model_internal function _doValidationForMiddleName(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfMiddleName != null && model_internal::_doValidationLastValOfMiddleName == value)
           return model_internal::_doValidationCacheOfMiddleName ;

        _model.model_internal::_middleNameIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isMiddleNameAvailable && _internal_middleName == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "middleName is required"));
        }

        model_internal::_doValidationCacheOfMiddleName = validationFailures;
        model_internal::_doValidationLastValOfMiddleName = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfPassword : Array = null;
    model_internal var _doValidationLastValOfPassword : String;

    model_internal function _doValidationForPassword(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfPassword != null && model_internal::_doValidationLastValOfPassword == value)
           return model_internal::_doValidationCacheOfPassword ;

        _model.model_internal::_passwordIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isPasswordAvailable && _internal_password == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "password is required"));
        }

        model_internal::_doValidationCacheOfPassword = validationFailures;
        model_internal::_doValidationLastValOfPassword = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfPersonalInfo : Array = null;
    model_internal var _doValidationLastValOfPersonalInfo : valueObjects.PatientPersonalInfo;

    model_internal function _doValidationForPersonalInfo(valueIn:Object):Array
    {
        var value : valueObjects.PatientPersonalInfo = valueIn as valueObjects.PatientPersonalInfo;

        if (model_internal::_doValidationCacheOfPersonalInfo != null && model_internal::_doValidationLastValOfPersonalInfo == value)
           return model_internal::_doValidationCacheOfPersonalInfo ;

        _model.model_internal::_personalInfoIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isPersonalInfoAvailable && _internal_personalInfo == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "personalInfo is required"));
        }

        model_internal::_doValidationCacheOfPersonalInfo = validationFailures;
        model_internal::_doValidationLastValOfPersonalInfo = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfSex : Array = null;
    model_internal var _doValidationLastValOfSex : String;

    model_internal function _doValidationForSex(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfSex != null && model_internal::_doValidationLastValOfSex == value)
           return model_internal::_doValidationCacheOfSex ;

        _model.model_internal::_sexIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isSexAvailable && _internal_sex == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "sex is required"));
        }

        model_internal::_doValidationCacheOfSex = validationFailures;
        model_internal::_doValidationLastValOfSex = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfSsn : Array = null;
    model_internal var _doValidationLastValOfSsn : String;

    model_internal function _doValidationForSsn(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfSsn != null && model_internal::_doValidationLastValOfSsn == value)
           return model_internal::_doValidationCacheOfSsn ;

        _model.model_internal::_ssnIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isSsnAvailable && _internal_ssn == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "ssn is required"));
        }

        model_internal::_doValidationCacheOfSsn = validationFailures;
        model_internal::_doValidationLastValOfSsn = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfState : Array = null;
    model_internal var _doValidationLastValOfState : String;

    model_internal function _doValidationForState(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfState != null && model_internal::_doValidationLastValOfState == value)
           return model_internal::_doValidationCacheOfState ;

        _model.model_internal::_stateIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isStateAvailable && _internal_state == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "state is required"));
        }

        model_internal::_doValidationCacheOfState = validationFailures;
        model_internal::_doValidationLastValOfState = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfUsername : Array = null;
    model_internal var _doValidationLastValOfUsername : String;

    model_internal function _doValidationForUsername(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfUsername != null && model_internal::_doValidationLastValOfUsername == value)
           return model_internal::_doValidationCacheOfUsername ;

        _model.model_internal::_usernameIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isUsernameAvailable && _internal_username == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "username is required"));
        }

        model_internal::_doValidationCacheOfUsername = validationFailures;
        model_internal::_doValidationLastValOfUsername = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfWorkPhone : Array = null;
    model_internal var _doValidationLastValOfWorkPhone : String;

    model_internal function _doValidationForWorkPhone(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfWorkPhone != null && model_internal::_doValidationLastValOfWorkPhone == value)
           return model_internal::_doValidationCacheOfWorkPhone ;

        _model.model_internal::_workPhoneIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isWorkPhoneAvailable && _internal_workPhone == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "workPhone is required"));
        }

        model_internal::_doValidationCacheOfWorkPhone = validationFailures;
        model_internal::_doValidationLastValOfWorkPhone = value;

        return validationFailures;
    }
    

}

}
